    <?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */

class b2c_ctl_site_prizeactv  extends b2c_frontpage{

    var $noCache = true;

    public function __construct(&$app){
        parent::__construct($app);
        $this->_response->set_header('Cache-Control', 'no-store');
        if(!$this->action) $this->action = 'index';
        $this->action_view = $this->action.".html";
        $this->objMath = kernel::single("ectools_math");
    }


    public function index()
    {

        $this->page('site/prizeactv/index/index.html',true);
    }

    /*
     *  摇奖转盘
     */
    public function xxjong()
    {
        $res  = $this->app->model('prizeactivity')->getList('*',array('activity_type'=>'activity1'));
        $this->pagedata['jsonListData'] = $res ;

        $this->page('site/prizeactv/xxjong.html',true);
    }


    public function instData()
    {
        $res  = app::get('b2c')->model('prizeactivity')->getList('*',array('activity_type'=>'activity1','prize_id'=>$_REQUEST['prize_id']));

        $param['activity_type'] = $_REQUEST['activity_type']?$_REQUEST['activity_type']:'activity1';
        $param['prize_name'] = $res[0]['prize_name'];
        $param['member'] =  $_COOKIE["CookieID"];
        $param['create_time'] = time();

        $objMdl =app::get('b2c')->model('prizemember');
        try {
            $res = $objMdl->save($param);

            die(json_decode(array('status'=>1, "message"=>"添加成功") ));
        }catch (Exception $e) {

            die(json_decode(array('status'=>0, "message"=>$e->getMessage()) ));

        }
    }
    //取奖品
    public function  getPrizeList() {

        $res  = app::get('b2c')->model('prizeactivity')->getList('*',array('activity_type'=>'activity1'));

        echo (json_encode(array('status'=>count($res)>1?1:0, "dlist"=>$res)));
    }

    //抽奖页面- 刮刮乐
    public function dList() {
        $type = $_REQUEST['a']?$_REQUEST['a']:'activity1';
        $res  = app::get('b2c')->model('prizemember')->getList('*',array('activity_type'=>"{$type}",'member'=>$_COOKIE["CookieID"]));
        $this->pagedata['dlist'] = $res ;

        $this->page('site/prizeactv/resultlist.html',true);
    }

    //抽奖页面- 刮刮乐
    public function ggkan() {
        $this->page('site/prizeactv/ggkan/index.html',true);
    }


}
